#override("title")
SpringWind - 用户管理
#end
#override("css")
<link href="#springUrl('/static/css/plugins/bootstrap-table/bootstrap-table.min.css')" rel="stylesheet">
#end
#override("breadcrumb")
<li><a>权限管理</a></li><li class="active"><strong>用户管理</strong></li>
#end
#override("content")
<div class="row">
	<div class="ibox-content text-right form-inline" style="background: #F3F3F4;">

        <select id="seachKey" style="width: 70px;height: 35px;padding-bottom: 7px">
            <option value="employeename">按姓名</option>
            <option value="employeenum">按职工号</option>
            <option value="employeeid">按ID</option>
            <option value="departmentname">按部门</option>
        </select>

        <div class="input-group">
			<input type="text" class="form-control" id="keyword">
			<span class="input-group-btn">
				<button type="button" class="btn btn-info" onclick="seach()">搜索</button>
			</span>
		</div>
		<button class="btn btn-primary" onclick="editEmployee(null)" type="button">
		<i class="fa fa-pencil"></i>&nbsp;添加用户</button>
	</div>
</div>
<div class="row">
    <div class="col-sm-12">
        <table id="dataTable">
        </table>
    </div>
</div>
#end
#override("js")
<script src="#springUrl('/static/js/plugins/bootstrap-table/bootstrap-table.min.js')"></script>
<script src="#springUrl('/static/js/plugins/bootstrap-table/bootstrap-table-mobile.min.js')"></script>
<script src="#springUrl('/static/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js')"></script>
<script src="#springUrl('/static/plugins/layer-v2.2/layer/layer.js')"></script>
<script src="#springUrl('/static/js/base_list.js')"></script>
<script src="#springUrl('/static/js/common.js')"></script>
<script type="text/javascript">
    var dataUrl = "#springUrl('/attendance/getAttendanceList.html')";
    var dataColumns = [{
        field: 'id',
        title: 'ID',
    }, {
        field: 'employeename',
        title: '姓名'
    }, {
        field: 'departmentname',
        title: '部门'
    }, {
        field: 'employeeid',
        title: '员工ID'
    },{
        field: 'date',
        title: '请假日期'
    }, {
        field: 'createtime',
        title: '创建时间',
/*        formatter: function (value, row, index) {
            return formatDate(row.crTime);
        }*/
    }, {
        field: 'changetime',
        title: '最后更新时间',
/*        formatter: function (value, row, index) {
            return formatDate(row.lastTime);
        }*/
    },{
        title: '操作',
        formatter: function (value, row, index) {
            var id = row.id;
            return '<a class="btn btn-xs btn-warning" onclick="editEmployee(' + "'" + id + "'" + ')"><i class="fa fa-pencil"></i>编辑</a> '
//                    +'<a class="btn btn-xs btn-warning" onclick="attendance(' + "'" + id + "'" + ')"><i class="fa fa-pencil"></i>考勤</a>'
                    <!-- 此处按钮级别权限控制，目前只有 admin 拥有该权限！ -->
                    #if($SSOPermission.isActionable("10010"))
                    + '<a class="btn btn-xs btn-danger" onclick="delAttendance(' + "'" + id + "'" + ')"><i class="fa fa-remove"></i>删除</a>'
                    #end;

        }
    }
    ];
    function dataQueryParams(params) {
        return {
            _size: params.limit,  //页面大小
            _index: params.offset, //页码
        };
    }

    function delAttendance(id) {
        //询问框
        layer.confirm('确定删除吗？', {
            btn: ['确定', '取消'] //按钮
        }, function () {
            $.ajax({
                type: "POST",
                url: "#springUrl('/attendance/deleteAttendance/')" + id,
                datatype: "text",
                success: function (data) {
                    if(data == 'true'){
                        $('#dataTable').bootstrapTable('refresh',{url:dataUrl});
                    }
                    layer.closeAll();
                }
            });
        }, function () {
            return;
        });
    }

    function attendance(id){
        var title = "新增考勤";
        var url = "#springUrl('/employee/Attendance.html')";
        if(id!=null){
            title = "考勤记录";
            url = url + "?id=" + id;
        }
        layer.open({
            type: 2,
            title: title,
            shadeClose: true,
            shade: 0.8,
            area: ['600px', '430px'],
            fix: false,
            maxmin: true,
            content: url
        });
    }
    function editEmployee(id){
        var title = "新增用户";
        var url = "#springUrl('/attendance/editAttendance.html')";
        if(id!=null){
            title = "编辑用户";
            url = url + "?id=" + id;
        }
        layer.open({
            type: 2,
            title: title,
            shadeClose: true,
            shade: 0.8,
            area: ['600px', '430px'],
            fix: false,
            maxmin: true,
            content: url
        });
    }


    function seach() {
        var value = $("#seachKey").val();
        var keyword = $("#keyword").val();
        keyword = window.encodeURI(window.encodeURI(keyword));

        var url = "#springUrl('/attendance/seach.html')";
        url="#springUrl('/attendance/seach/')" + value+"_"+keyword
        $('#dataTable').bootstrapTable('refresh',{url:url});
//        $.ajax({
//            type: "GET",
//            url: "#springUrl('/employee/seach/')" + value+"_"+keyword,
//            datatype: "json",
//            success: function (data) {
//                if (data != null) {
//                    $('#dataTable').bootstrapTable('refresh',{url:url});
//                }
//                layer.closeAll();
//            }
//        });
    }


</script>
#end
#extends("/common/framework.html")
